refactor battle