Selection algorithm simplified.

fixes #322