fixed the battle function