added info about the working of algorithm