refactored clean.py