Code refactoring (part 1)