I think the focus of @bkgood is slightly different. But I am sure there is much room for improvements in my solution.
So lets take this as an intermediate version.