Uganda’s Constitutional Court struck down a law that punished “attempted homosexuality” with a life term in prison. The court did not base its decision on any humanitarian impulse, however. It invalidated the measure because its enactment was procedurally flawed, according to the AP.

The anti-gay measure provides for jail terms of up to life for those convicted of engaging in gay sex. It also allows lengthy jails terms for those convicted of the offenses of “attempted homosexuality” as well as “promotion of homosexuality.”

It has been condemned in the West and rights groups have described it as draconian. The U.S., which wants the law repealed, has withheld or redirected funding to some Ugandan institutions accused of involvement in rights abuses.

The law was passed by lawmakers in December and enacted in February by Ugandan President Yoweri Museveni, who said he wanted to deter Western groups from promoting homosexuality among African children.