add pseudocode for 3rd implementation