added a few notes and fixed algorithm error