fixed a bug in login/logout function