Fixed errors with login function