Fix undetected variable error (stupid R's scopelessness)