fixed error in ensureCorrectDimensions