fix bugs for login page and add features of error detection