Perform extract function refactoring