Minor refactoring for erasing repeated code.
Merge pull request #65 from javierj/master

Minor refactoring for erasing repeated code.