fix time calculation