Add case when connection fails
Bugfix