Same results as v1. Much less code.

Keeping v1 for reference.