added logic for submenus