improved performance of matrix stuffing