Rewrite the next highest number algorithm, all working now.