more checks to avoid errors in execution of javascript on IE8