Apologies; I'd prefer to define it at the top of the function than in the loop. Meant to delete the loop declaration.