Helper util for 3d arrays