enhanced cross-browser version