completed cachematirx.R