Refactor & Add support for non-ES5 browsers

I have cleaned up the code a bit and kept your original steps and variables. You were using `Array.prototype.forEach` which is part of ES5 and doesn't work on older browsers. I have tested the script on a current project of mine, and it works flawlessly. 

Thanks a lot! :)