also optionally work on refs
use reftype named packages instead of 0