rework menu dialog code to allow easier maintenance