added null check and removed xml formatter