Generate variable names with a function, suggested by @mshonle