Changed Array.prototype.slice to reverse for loops and tested successfully in IE9
Minor refactor