properly declare vars to avoid global scope

current implementation leaks global variables for `_`