Adjusted code to get rid of redundancy.
Merge pull request #44 from Jedwondle/master

Adjusted code to get rid of redundancy.