Fixing array bug in makeObjectArray function