refactor pkg_set_type