fix bug which caused the browser to die because of an infinity loop