finish login function