implement smarter package detection