Replaced Array.forEach with simple for loop

For better backward compatibility. (IE8 etc)