handling connection errors better