add percentile check
allow for nulls in average check with -n setting
replace map with each as per @nstielau review comment