Fix bug in jobs query