Bug fix. variable defined only inside a conditional was used inside.