update code for 3D