more logic for time calculation