Joining Functions

Refactorizing code to do the merge ~