Added cyril's algorithm for dynamic