update to handle up to 3 dimensional cube so that we call scoreatprecentile with
only upto 2d data.