Fix Error in provider

Calling local var outside of block