Problem 8 solved

And finally in a neat manner =)