debuged the battle function