Added simple BuildQuery function.