improved mxn diagram construction