Code refactoring