remove redundant for loop