fix time calculations