fixed ClassCastException in unregister method