modified purge_pipeline