Fix bugs when row and column numbers are different