the code for an attempt at correcting the velocity issue