Refine filter.py