A Texas court has ruled that the state’s anti-“creepshot” law, intended to keep people from secretly taking photos for sexual arousal, is unconstitutional because it violates the free speech clause of the First Amendment.

The decision was made by the Texas Court of Criminal Appeals on Wednesday in a case over Ronald Thompson, a man charged in 2011 with 26 counts of improper photography for taking underwater photos of children at a San Antonio water park. Though most of the children were wearing swim suits in the photos, the law prohibited any photos “made with the intent to arouse or gratify the sexual desires of any person.”

In the decision, the court said the law was too broad. “This statute could easily be applied to an entertainment reporter who takes a photograph of an attractive celebrity on a public street.”

Peter Linzer, a professor at the University of Houston Law Center, told the Houston Chronicle that it was “hard to see” how a state could make the act of taking a picture a crime.

“You can’t prevent someone in public from looking at you and having dark thoughts,” he said.