fixed issue with more then 2 dimensions.