documented mainactivity and refactored it