split this up.. a first step would be to pull out the numpy.size(scored_pairs, 1), which you call again on line 122