fixed bug in unref