Added comments and improved code readability
Improved code and added comments