add connection error checking