optimize main layout