login logout refactoring