Correct layer adding scheme to avoid crash in diffusion, not perfect though