now threshold is a variable as opposed to hard-coded value