Fixed js hanging problem