logout refactored