Patch 1

Switched the var to outside the function as it wasn't working inside.