The Supreme Court of Canada has ruled in a 4-3 decision that law enforcement can search someone’s phone when they get arrested—but that such a search must be directly connected to that arrest and the officers must keep detailed notes.

The Canadian decision offers a significant difference between a related decision (Riley v. California) from the United States Supreme Court, which ruled 9-0 in June 2014 that law enforcement cannot search an arrestee’s phone unless they have a warrant.

The Canadian case, known as Kevin Fearon v. Her Majesty the Queen, revolves around a woman operating a jewelry stall in July 2009 at a flea market in Toronto’s Downsview neighborhood. Toward the end of the day, as the victim was packing up, she was held at gunpoint by two men and was ordered to open her car. The men took an estimated CAD$10,000 ($9,800) to CAD$40,000 ($39,200) worth of jewelry.

A Toronto police officer, based on eyewitness accounts and information that she filed with the authorities, drove to a nearby apartment building where he thought one of the suspects might live. More officers later arrived for backup.

Kevin Fearon and Junior Chapman were quickly identified and arrested on the charge of robbery with a firearm and were also advised of their rights to counsel.

Previously, the Court of Appeal for Ontario ruled that because Fearon had not put a passcode on his phone, it was OK for law enforcement to search it.

According to the Supreme Court of Canada opinion, police conducted a pat-down of Fearon upon his arrest and found his phone. Police searched the phone itself and found a draft text message which read, "We did it were the jewelry at nigga burrrrrrrrrrr," and some photos, including one of a handgun.

The opinion also detailed the precise conditions when Canadian law enforcement can search a phone: