handle 3D and 4D shape