Added 3D and 2D versions