added threshold functions, percentile function