size selection algorithm working