Slightly more elegant, now works in chrome.