spam refactoring