fixed logout logic