Moved switch after for loop.