refactored MainActivity