Implement sign out and refactored