wrapped switch statement in for loop