Fix query error in 40_scope

Closes #193