add algorithm and Jon Skeet's answer