fix logic for autodetecting package