content cleaning refactored