The lake froze solid and the Weasley twins were punished for bewitching several snowballs so that they followed Quirrell around, bouncing off the back of his turban.
I'm confused by the usage of "so that" in this sentence. "So that" usually means "in order that", but "bewitching several snowballs" is unnecessary for them to follow Quirrell around. In other words, they don't really have to bewitch snowballs in order to follow Quirrell around. Anyway, I may simply misunderstand what the whole sentence is trying to convey. Can someone help me to understand it?
--excerpted from Harry Potter.