uploaded complete pseudocode