Added dynamic threshold capability