First solution, passing tests
Refactor to reduce variable clutter