moved xml parsing to a separate function