Complete the login function