flatten to 2d (working)