factor out readXHR