fixing matrix3d bug