added some generality to the ring gap case