Rewrote the code explanation and summary