fix the bug of menu

use closure to fix the menu bug