added comments for explanation of execution