fixed some bugs & finshed the rigister part