fix bug for hiding menus correctly