modified listPackages function