Fix the time calculation