added specs and code for velocity calculation