Reusable function refactoring.