hijing: restricted loop to stay in matrix dimension boundaries.

should make no difference but remove compiler warning