changed logic to be more flexible for auto-pack existing packages, final function left