Better solution.
Naive implementation.