added a velocity function