added trigger threshold logic