History query build method updated