I have added code comments clarifying the same as I mentioned above.