Correct bug in subroutine reducing_matrices