changing to sparse matrix. bug is found