DRY up the menu handling code.