returning proc from expand_query, corrected