updated fixed a bug in the dynamic algorithm