RIO DE JANEIRO (AP) — Michael Phelps goes for history — again — and Katie Ledecky is set up to make some of her own in the Olympic pool.

Phelps will be doing double duty Thursday night. He'll swim the 200-meter individual medley final in pursuit of a record fourth consecutive title in the event and return about 30 minutes later for the 100 butterfly semifinals.

No swimmer has ever won four golds in the same individual event in consecutive Olympics. Only two athletes, discus thrower Al Oerter and long jumper Carl Lewis, ever have managed the feat.

Phelps qualified fourth fastest in 51.60 seconds for the 100 fly. If he gets through to Friday's final, he'll also be seeking his fourth gold in a row in that event.

Winner of three golds already in Rio, Phelps duels longtime friend and rival Ryan Lochte in the 200 IM. Phelps made a tactical error, though, in the 100 fly heats. He was aiming to get into the second semifinal, which would have given him some extra recovery time after the 200 IM final.

"But I screwed up,'" he said. "I try not to even think about it because then I get focused on that. But I'd like to have those extra seven, eight minutes in between."

By competing in the first semi, Phelps has less time to warm down after the 200 IM.

"Obviously, the first one (200 IM), I need to take care of business," he said. "Whatever I can do in the second one (100 fly) just to make it through is what I'll do."

Joseph Schooling of Singapore topped the 100 fly heats in 51.41. Hungary's Laszlo Cseh was second quickest in 51.52, while American Tom Shields was third at 51.58. Also advancing were Chad le Clos of South Africa, James Guy of Britain and Santo Condorelli of Canada.

Ledecky easily qualified first in the 800 freestyle, with an Olympic-record time of 8 minutes, 12.86 seconds. The 19-year-old American was nearly seven seconds faster than anyone else.

If she wins the final on Friday, Ledecky will become the first swimmer since Debbie Meyer in 1968 to sweep the 200, 400 and 800 freestyles.

"I try not to think too much about the history of anything," said Ledecky, who didn't get to bed until after 3 a.m. after anchoring the U.S. women to victory in the 4x200 free relay on Wednesday. "It's all just about doing my best every time."

Boglarka Kapas of Hungary qualified second for the 800 free in 8:19.43. Others making the final were Jazz Carlin of Britain, American Leah Smith, Lotte Friis of Denmark and Mireia Belmonte Garcia of Spain, who won the 200 butterfly on Wednesday.

Andriy Hovorov of Ukraine was the fastest qualifier in the men's 50 free at 21.72. Two years ago, Russia annexed his home of Crimea and he rejected changing nationality. Helped by funding from Ukraine's meager sports budget, Hovorov is in position to win swimming's glamour event.

"This has all been in my training plan since January, and I qualified with the top result," Hovorov said. "I'm going to keep it up."

A pair of Americans, Nathan Adrian and Anthony Ervin, had the second and third best times in the heats. Adrian, bronze medalist in the 100 free on Wednesday, touched in 21.61. Ervin, the 2000 Olympic champion in the 50, was clocked in 21.63.

Also advancing to the semis were defending champion Florent Manaudou of France, Cameron McEvoy of Australia, Vladimir Morozov of Russia, Santo Condorelli of Canada and Bruno Fratus of Brazil.

The Iron Lady is chasing her fourth gold medal.

Katinka Hosszu of Hungary qualified fastest for the 200 backstroke in 2:06.09. She already has won the 100 back, along with the 200 and 400 individual medleys.

Hilary Caldwell of Canada had the second quickest time of 2:07.40. Maya DiRado of the United States, who has won gold, silver and bronze at her first Olympics, was third fastest in 2:08.60.

Defending champion Missy Franklin advanced to the semifinals with the 11th-fastest time of 2:09.36. She missed the 200 free final in her only other individual event in Rio.

"Right now, I'm taking it one race at a time," said Franklin, who is struggling to understand her puzzling lack of form this year. "My goal is going to be making it into the finals."

Franklin earned a gold medal as part of the 4x200 freestyle relay in Rio after swimming in the preliminaries.

Kirsty Coventry of Zimbabwe, a two-time Olympic champion in the 200 back, qualified ninth.