fix bugs for logining