Added logic for login/logout