Fixed bug in new select algorithm. Now works.