add dynamic plan algorithm.