Updated documentation and refactored code.
updated documentation
provided some refactoring on the code