use accumulate instead of loop
change the way of select
final