Added code comments for better understanding