Fixed nil reference in time comparison