Revert "Revert "Restructuring logic and removing duplicated code""
Merge pull request #12 from nmadhok/revert-11-revert-10-restructure-logic

Revert "Revert "Restructuring logic and removing duplicated code""