fixed logout function