added comments for clearity