Added comments throughout the code