Although we are calling this a scale tone melody, notice how many of the scale tones are also chord tones. Also notice two critically-important structural elements:
First, that each scale-wise passage crosses over the bar to a definitive chord tone at the beginning of the next measure.
Second, that the melodic rhythm and contour in the first four bars is identical to the last four bars. These kind of unifying patterns give compositions and improvisations a coherence that is both logical and musical.