added threshold support