New algorithm for finding elements by position