added purge and split out common code between mehtods