Fixing intermitent issue with JavaScript engine