more examples
Refactor into general version that can be called in 2D or 3D case