put time comparison in separate function