check the length of password and fixed some bugs