refactoring login bits