this looks fragile, I think each patch should receive the Y to patch as an argument, that way they are monadic functions.