refactoring of MainActivity template