fixing array.length only when array of objects