more refactoring of the login module