moved unregister notification to end of block