refactor setDynamic method.