Bug fix for the logout function