step 5 of Algorithm