DRYs up UI, adds validation and some error checking