Quick'n'dirty implementation.

It should use streams for better feedback.