I should have thought of using local variables. I am trying to avoid them because it's more fun to read and write that way, but (grad) kinda needs them if not the others. I think you made a couple minor mistakes: in (bases) you call basis instead of (basis), and in (grad) I think you need to call the quotes (i.e. "loc quot call" instead of "loc quot"). After that correction though I will definitely be using your (grad) code. Thanks!