Fixed variable scoping problem

If you don't put `value` into a new var inside the function, it will stay that value across different executions of the function