fix copy_matrix