Optimize checking installed packages