added missing m and n + minor improvement