Refactor smart menu to support history