added algorithm comments