fixed calculateSpeed