add threshold support for aggreagation