refactoring : extracted function