Fix up login function