Chris Brown is going back to rehab, this time with new rules dictated by a judge.

Los Angeles Superior Court Judge James R. Brandlin on Wednesday ordered Brown to serve three months in a residential treatment facility and to submit to drug testing. The judge also ordered the R&B singer to perform at least 24 hours of community service per week.

Brown appeared in court for the first time since he was arrested last month on a misdemeanor assault charge in Washington, D.C. Since then, he voluntarily entered and left a rehab program for anger management.

Brown’s attorney Mark Geragos said the terms imposed by the judge were recommended by probation officers and the singer has agreed to abide by them.

The Grammy winner may still face a probation violation for the incident in Washington; Brandlin ordered probation officials to gather additional details about the case and report back for a Dec. 16 hearing.

A 20-year-old man accused Brown of punching him after he tried to get in a photo with the singer. Brown denied to police that he hit the man but was charged with misdemeanor assault and is due to appear in court Monday.

Brandlin said Brown is allowed to travel for the hearing if necessary, but his ruling makes clear that the expectation for the singer for the next few months is to receive treatment and perform community service such as graffiti removal or roadside cleanup.

Earlier this year Brown was ordered to redo 1,000 hours of community labor that are part of his sentence for felony assault in the 2009 beating of Rihanna, his girlfriend at the time.

The singer appeared in court Wednesday with his girlfriend Karrueche Tran and spoke only once, to acknowledge that he agreed to the terms imposed by the judge.

At Geragos’ request, Brown was also ordered to take any medications his doctor prescribed.