we should iterate from right-most column in matrix