Added explanation of algorithm