refactored velocity calculations