fix matrix condition check