Fix switching height and wdith in a for loop