Added logic for xml_split and broke some code into a sub