Refactoring: some code extraction
Refactoring