Refactoring dirty code