added algorithm and accompanying text