fixed bug: menu can be undefined.