optimized OnRegister and OnUnregister methods extraction