Refactored the solution
Merge pull request #2 from mallu-patil/Solution-Refactor

Refactored the solution