Added error handling in case of no connection.