algo2: index function moved out
algo2: elements' class introduced
algo2: removed comments