ALLENTOWN, Pa. (AP) — A Pennsylvania appeals court reversed a judge’s ruling that state police didn’t have a valid legal reason for searching a car just because it smelled like cannabis, saying she failed to weigh other factors that led to the man’s arrest.

The state Superior Court agreed with Lehigh County Judge Maria Dantos that the smell of marijuana alone is not enough to give police the right to search a car without a warrant. But the appeals court reversed her decision to suppress evidence in Timothy Barr’s arrest, saying Dantos didn’t take other evidence into account in weighing the legality of the search, The (Allentown) Morning Call reported Friday.

The appeals court sent the case back to Lehigh County Court for review. Another judge will handle the case since Dantos has since retired.

The police search yielded a loaded handgun and a small amount of marijuana in an unmarked plastic baggie. Barr, a passenger in the car, was charged with illegally possessing a firearm and possessing a small amount of marijuana. But Dantos suppressed the evidence, noting Barr had a medical marijuana card.

In her opinion last year, Dantos wrote that “the ‘plain smell’ of marijuana alone no longer provides authorities with probable cause to conduct a search of a subject vehicle,” because it’s “no longer indicative of an illegal or criminal act.” She said that once Barr presented his medical marijuana card, it was “illogical, impractical and unreasonable” for troopers to conclude a crime had been committed.

Prosecutors appealed, and Superior Court said Dantos’ decision to suppress evidence in Barr’s arrest was not legally sufficient.

Barr’s attorney, Joshua Karoly, called the ruling a victory, “but one which could have been clearer and more robust.” He said the appeals court “expressly rejected” most of the prosecution’s arguments.

Prosecutors argue the search was legal under state Supreme Court precedent.

For nearly 100 years, the U.S. Supreme Court has recognized an “automobile exception” to the Fourth Amendment’s ban on unreasonable searches and seizures, giving law enforcement the right to conduct a warrantless search if there is reason to suspect a vehicle is hiding contraband or evidence of a crime. Police have long used the exception to conduct vehicle searches based on the pungent, distinctive odor of pot.

Increasingly, motorists in states where marijuana is legal in some form are pushing back when police insist on a search, especially if that search yields evidence of a crime.

(©Copyright 2020 by The Associated Press. All Rights Reserved.)