Fixed HXP.next()

HXP.next() was using max() for the non-looping branch instead of min()