Refactored a bit of the mainactivity