cached inverse matrix solving implementation added