It was actually. But you do raise a valid point, which I had not thought of earlier. Right now towers choose the next in line if a current target gets out of range. But that may not always be the best choice if the maximum damage left, is less than the health of that target.

It seems I need to add a few more variables to the equation.
An interesting problem though