You should capture the return value & unregister first when not null