added algorithms in comments