finish the register function.