first approach with dynamic nodes