bug in time calculation