Generalizing commands through loops