implement threshold; cleanup