Fixed the time calculation