refactor how logging out is done