reducing code complexity in packages_controller