Refactor main activity