Added refactored code. Hope this helps.
Merge pull request #1 from rjbernaldo/patch-1

Added refactored code. Hope this helps.