Refactoring and avoid boilerplate code
some changes after revision
Merge pull request #1 from viavansi/refactor

Refactoring and avoid boilerplate code