Refactored menu creation code