Refactor repeated code
Merge pull request #3 from ben-spoon/refactor-all

Refactor repeated code