DRYing out the code
Merge pull request #186 from fabiomcosta/master

reducing code duplication