algorithm details