corrected array size of P n*m to m*n