Added upper and lower threshold