Made better code for rings