fixed broken element selection logic