tidy up of code in mainPageViewController