optimize main activity