fixes to time calculation