Former Glee star Mark Salling has officially pleaded guilty to possession of child pornography, two years after his initial arrest back in December 2015.

According to TMZ, the 35-year-old appeared in a Los Angeles court earlier on Monday (US time) and pleaded guilty, in keeping with his October plea deal. He now faces 4 to 7 years in prison when the judge hands down his sentence next March.

The outlet reports that if he’d entered a “not guilty” plea, Salling could have faced up to 20 years in jail.

The actor was arrested after LAPD officers raided his home, with TMZ reporting that police found “more than 50,000 thousands images of child porn… [of children] aged 3 to 5” on his computer.

The publication claims that an ex-girlfriend of Salling’s tipped off the police after he showed her the images on at least two occasions.

As we previously reported when Salling struck the plea deal, court documents indicated that he must register as a sex offender, have no communication with anyone under the age of 18 (unless in the presence of a parent or guardian) and will be under supervised release for 20 years.

He’ll also fall under the usual restrictions of registered sex offenders, being required to stay 100 feet (about 30m) away from schoolyards, parks, public swimming pools, playgrounds and video arcade facilities at all times.

Image: Getty Images / Jason Kempin