Sunday’s ruling upheld an appeal filed by an Israel Defense Forces (IDF) soldier who was convicted of helping a fellow soldier obtain drugs based on evidence found in a search of his phone.

The soldier had agreed to have his phone examined, but the appeals court deemed the search to be illegal, and overturned the conviction, Haaretz reported.

The ruling puts an end to searching soldiers’ phones without a warrant, which was previously allowed as long as consent was given. Cellphone laboratories can provide access to a large range of cell phone data – including that previously deleted by the user.

However, military police have forced some soldiers to give consent by threatening to confiscate their phones or indict them, Haaretz reports.

Of the more than 2,200 phone searches conducted by military police each year, some 80 percent are typically done without a warrant, according to information obtained under the Freedom of Information Act by Adi Rittigshtain Eisner, the military defense attorney that filed the appeal.