Fixed algo used to retrieve matching packages