refactor login check