fix possible bug when a user was registered or unregistered