Dynamic algorithm