fixed problem 1 to use M dimensions instead of 3