rewrited login function