Added feature detection to prevent error in IE8