Refactor of MainActivity