moved logout function.