Refactored and added XML indenting