re-implemented velocity calculation