fina l connection with error handling