changed the builder around a little, now iterating over m, not D, this is more sensible