fix bug where dimension != 2 cause assertion errors