refactored x_next