updated for cross-browser compatibility