refactor of mainActivity