fixed percentile_profile function