merge the for-if statement