added retrying in case of failed connections