added comments for more clarity