improve unregister method