Update README.md
Added code documentation and some refactor were made to make the code more legible.