updated pseudocode with some missing instructions