Refactored your code

Hey Ben, refactored your code a little. Hopefully it's clear enough for you to learn from it! Let me know if you have any questions :) 

Mart in Moscow.