Refactoring login module