Minor bug with query