main xml load logic refactor