Implemented purge function