catching IOException in case of disconection