Wrote a little polyfill function to get things working in firefox