Pseudocode and comments

Pseudocode and comments for the code