added calculate velocity