fix #520 for JS