Added connection error hadnling