refactored menu code.