Commenting and updated pseudocode