worked quantile and logical indexing into real templated utility functions