basic matrix caching added