fix a bug with login function