Added pseudocode from lecture