fix the package matching function