refactor main activity