code improvements

modified iteration; modified stacked layout