Refactoring (extract function)