Ok, done. its not needed.
i used ' editRenderLayerGlobals -currentRenderLayer $layerName; ' to set renderLayer in a loop
instead of using ' setAttr "renderLayerManager.crl" $indx; '
so that i dont have to get layer indx (startting frm bottom to top in channelBox).