I agree reads a bit grossly, I've had a go outside the actions but I have not found a cleaner way that I am confident works. I've been looking for examples where this sort of thing has been cleanly abstracted but I have found none in any other cookbooks I've checked.