modified code with respect to the computation of the number of layer-points instead of hard-coding based on the model