updated singleton code