Multiple rendering causing a ul more
I have found the answer of it since in render variables are passed by reference https://api.drupal.org/api/drupal/includes!common.inc/function/render/7

so i was passing $main_menu_expanded multiple times in render which was culprit.

Fix is

$variables['main_menu_expanded'] = render(menu_tree_output($main_menu_tree));
&lt;?php if ($main_menu): ?&gt;
                    &lt;div id="main-menu" class="navigation"&gt;
                        &lt;?php print ($main_menu_expanded); ?&gt;
                    &lt;/div&gt; &lt;!-- /#main-menu --&gt;
&lt;?php endif; ?&gt;

&lt;?php if ($main_menu): ?&gt;
                    &lt;div id="main-menu" class="navigation"&gt;
                        &lt;?php print ($main_menu_expanded); ?&gt;
                    &lt;/div&gt; &lt;!-- /#main-menu --&gt;
&lt;?php endif; ?&gt;


Now i dont get extra ul