Refactoring function definition