added stencil code