Improve dynamic completion algorithm