Refactoring the menu generation