Solution by Quinn Heiner

It's messy, but it works.
Merge pull request #7 from quinn2002/master

Solution by Quinn Heiner