Optimized the menu xml conversion code