updated stringify function