fixed iteration through all objects at getObjectByName

this code only checked the first objects element