remove common process in branch block and implement some class for loop detection