modified doLayout and chooseLayout

modified doLayout and chooseLayout