organize code of main activity