completed select threshold function