fix negative numbers in matrices