applied Szabolcs proposal to simplify setlayout()