copied prev code from simring