map upper lower search, erase visited elements