Flies can anticipate and elude the swats of humans, a new study has found.

Within milliseconds, fruit flies can alter their body position to be properly prepared to jump in the direction of safety as an object hurtles toward them, the study by Michael Dickinson of the California Institute of Technology found, according to the Times of London.

“We were surprised to find that long — in fly time — before a fly takes off in response to a predator or swatter, it plans the direction of the jump by making a rather complex series of postural movements,” Dickinson said in the study, published Thursday in the journal Current Biology.

“These movements are made very rapidly, within about 200 milliseconds, but within that time the animal determines where the threat is coming from and activates an appropriate set of movements to position its legs and wings," he continued. "This illustrates how rapidly the fly's brain can process sensory information into an appropriate motor response."

Dickinson's team used high resolution, high-speed imaging technology to film the flies in the study, the Times said.

“We also found that when the fly makes planning movements prior to take-off, it takes into account its body position at the time it first sees the threat. When it first notices an approaching threat, a fly's body might be in any sort of posture, depending on what it was doing at the time, like grooming, feeding, walking, or courting," Dickinson said.

“Our experiments showed that the fly somehow ‘knows' whether it needs to make large or small postural changes to reach the correct pre-flight posture."

The study does have practical applications, according to the report.

“It is best to aim a bit forward of the fly's starting position, to anticipate where it is going to jump when it first sees your swatter,” Dickinson said.

Click here to read the full Times of London report.

Click here to read the study's summary at Current Biology.