added a fix to handle refused connection