improved selection logic