Optimized code and fixed Purge Filter