Refactor login checks