Db matrix generation fixed