cleaned up code in mainactivity