implement register user and fix minor bug