Fix bug with unscoped variable