Fix bug in login fuction