Share query
Move recursion to better place
factor out change generating