prototype version for flexible queries