Bug fix calcmatrix error