pseudo code for refine linking structure