Refactored Code as well as Added Docs.