Update algorithm #166 and #167