refactored login check