Pseudocode and comments added