modified purging script