fixing the unregister bug