added update function with velocity and acceleration