Added matrix support