updated completion algorithm