fixing usage of undefined variable in _callback function