Add 'run' function and convert 'next_number' function to use matching