MONTGOMERY, Ala. — Police in Alabama would have to collect data on traffic stops to prevent racial profiling, under a bill endorsed Wednesday by a committee in the state House.

The bill by state Sen. Rodger Smitherman, a Birmingham Democrat, would require officers to record the race of a person pulled over in a traffic stop. Police would submit data annually to the state attorney general’s office, which would withhold funds from agencies that didn’t follow the law.

Smitherman, who is black, said the bill’s purpose is to ensure drivers were only stopped for traffic violations. He shared his personal experiences about being pulled over five times without reason while driving luxury cars.

“I wasn’t in any violation of anything. I wasn’t cited or questioned,” Smitherman said. “It’s the life of an African-American in general and especially an African-American male. It has always happened and it has to stop.”

Smitherman also said he wanted to avoid a situation “like Ferguson and Baltimore,” referring to the deaths of unarmed black men at the hands of police officers that ignited protests.

Republican members of the House Judiciary Committee agreed with the bill’s intent but expressed concern about burdening police and the attorney general’s office with record-keeping. At a public hearing last week, Bobby Timmons of the Alabama Sheriffs’ Association said “the bill adds a whole lot of paperwork that we don’t have the personnel to do.” A representative from the attorney general’s office did not attend the hearing.

Smitherman said officers already record race in citations but should also have to document stops.

Rep. Allen Farley, a Republican who retired from a law enforcement career, said 99 percent of police “out there doing the right thing for the right reasons” would support the bill.

“No one wants to get rid of bad cops more than the good cops,” he said.

More than half of U.S. states do not require racial reporting on traffic stops, according to a 2014 NAACP report.

The bill passed on a voice vote with a few dissenting votes. It moves to a final vote on the House floor, where it didn’t pass last year.