initial working version of cachematrix