fix null reference js exception