Fix index failing when Object passed instead of Array