Made the recursive query interface a bit smarter