Cleaned up logic for getting next run number