refactor mainactivity