Simplified & fixed parsing of layer name