Fixed javascript to work in IE9 and older versions