Added comments.
Added comments.
Refactored code