bugfix for compute_velocity