remove redundant 'for' statements