added xml and refactor state file