more work on stencil functions