add timeout and checkNetwork function