Creating multiple groups from multiple surfaces

The smart quotes will cause issues when copying your code, so …
[How to] Post correctly formatted and colorized code on the forum?

Also please follow good coding style. (Put spaces before and after operators and properly indent code.)

You also commit an undo operation, but never start one.