Fixed a time calculation bug