Fix bug in time comparison