plan algorithm improved.