Title: An optimal selection algorithm