Updated to work cross browser.