refactored some code and added sign out functionality