Edited logout function