Refactoring speed calculation