error when object contains sub objects