proper implementation of linear rank selection