obj can be undefined, add checking