Add verify matrix range and move some methods in Utils class