refactoring function use