improved loops, introduce functions adjust_x_data