Found the bug!

The bug happens when two of the same column elements are 0 which means
that there was 0 multiplier between them. Which screws up the compare
statements. I need to find a better way to do this but at least I can
sleep tonight.