fix reference counter