fixed JS infinite refresh bug