Added matrix functionality