Code refactoring (part 1/2)