LOUISVILLE, Ky. -- A man appeared in court Wednesday after he was arrested over the weekend for allegedly impersonating a police officer and pulling over a real one.

CBS affiliate WLKY reports that Brandon Hurley, 24, did a U-turn and pulled up behind a vehicle driven by an off-duty officer with the Louisville Metro Police Department on Saturday night. Hurley began flashing his lights and honking his horn to get the officer to pull over, authorities said.

"The officer passed the defendant. The defendant then did a U-turn in the road and got behind affiant's vehicle," Judge Sean Delahanty said. "That's just some bad luck there."

Get Breaking News Delivered to Your Inbox

The off-duty officer pulled over, thinking Hurley needed help. But Hurley approached the vehicle and asked the driver if he knew he had hit a curb and how fast he was going, WLKY reports.

Officials said Hurley identified himself as a Jefferson County officer when the off-duty cop asked for identification. Hurley said he didn't have his badge and was confused when the driver identified himself as a police officer. When the real cop asked for his badge number, Hurley quickly got back in his car and sped off in the other direction.

Brandon Hurley, 24, appears in court after being arrested for allegedly impersonating a police officer. WLKY-TV

The officer wrote down Hurley's license plate as he sped away, WLKY says. He also said he recognized him.

"[The] officer believed he recognized defendant from high school, which is another bad break," Delahanty said. He said they did in fact go to the same school.

Hurley faces charges of impersonating an officer and second-degree wanton endangerment. He was ordered to turn over his flashing lights and return to court on Nov. 21.