might want to pull this elsewhere as many different implementations might use this. maybe a trait perhaps?