updated cache matrix functions