update matrix generation