add make_patch() function