correct the minor bug in selectfn()