fixing panic after connection error