[ADD] added more sophisticated query system