fixed bug in apply_dynamics