fix bug when registering