more pseudocode for auto-query