finished algorithm with webpages