reconstruction algorithm, not finished