remade the battleTime function to be reusable