Re-factor code to work with IE 9