added matrix support