Actress Amanda Bynes will escape prosecution in her drug possession case if she agrees to attend twice-weekly counseling sessions and stay out of trouble for six months.

The “Hairspray” star was charged with reckless endangerment, tampering with evidence and possessing marijuana after reportedly throwing a bong out of her window during a police raid on her New York apartment last May.

The case was delayed over the summer after the 27 year old was hospitalized for mental health concerns, but she completed a stint in a rehab facility in December, and her lawyers have been working with authorities to strike a plea deal.

The agreement was approved by a Manhattan judge during a hearing on Friday, when the official ruled that the case will be adjourned in contemplation of dismissal.

As a result, Bynes will not have to admit any guilt, but she must undergo regular counseling for six months and avoid further legal troubles during that period.

The actress was not in court for Friday’s hearing, but her attorney Gerald Shargel filed an affidavit declaring that Bynes understood the terms of the deal.

The settlement is good news for Bynes – she is also facing trial for a charge of driving under the influence relating to an arrest in 2012, when she was busted for allegedly side-swiping a California police car. However, prosecutors are reportedly in talks with her defense team to reach a plea agreement in that case, too, before a pre-trial date next month.