Fix bug of tool

fix the bug that when it occur recursion in first_list it will lose in
endless loop