solved a dynamic problem