Try to follow along. In Texas, it's legal to have sex with somebody as young as 17 years old. But it's considered child pornography to have nude pictures of somebody under 18, even if he or she is 17.

This means a 51-year-old Houston math tutor is facing 20 years in prison and may have to register as a sex offender for life in connection to accusations that his mobile phone contained child pornography—which were the nude photos that his 17-year-old student-girlfriend had texted him. The case against Aldo Leiva came to light after the girl's mother found explicit pictures on her daughter's mobile phone. The Houston Independent School District Police Department opened an investigation, which led to the charges against the Houston High tutor, according to court records.

Leiva posted $20,000 bond last week, and a local judge issued a no-contact order between the girl and the tutor. According to court records (PDF), the tutor gave police his phone and unlocked it for them, and nude images of the girl were allegedly recovered.

"We entrust our educators with the care of all children, and that includes 17-year-olds," Assistant District Attorney Patrick Stanton told the Houston Chronicle. "It's someone who was placed in a position to do a job and that job did not include developing inappropriate relationships with students that were in his care."

In addition to child-porn possession allegations, the tutor is charged with inducing the girl to send him nude photos—an alleged crime called "performance by child," according to court documents. The girl told investigators that the couple had a consensual sexual relationship.

The court record alleges that the two engaged in Batman-and-Robin-style sexual fantasy role-play via text messages.

"She's indicated to me that she wants to continue to have contact with him," Gary Tabakman, the defendant's attorney, told the Chronicle. "I would say that the aspects of this case are consensual, across the board."

Leiva's next court appearance is July 1.