refactored special package processing code