added refcount calculation