refactor to avoid a cast in QueryExecutor