added matrix condition