Converted some array.length to array.push