update login function and checklogin