fix the layer_counter bug