threshold funtion added