Rreduce code duplication
Merge pull request #286 from alex/code-duplication

Rreduce code duplication