2nd attempt to fix endless loop in firefox/chrome