Added some code to allow for 3d