Fix logic bug in addLayerGroup