logout function modified