edited login function