Refactoring menu item enable code