fix bug in login function