pseudo code in doc for step 3