prevent js error when no connection