split get_package_list into a few functions