factor out object iteration