replace switch with if-else, to define the layer type