added matrix casts