revised to fix negative of matrix