Refactored purge method to allow for compacting