Problem 1 plus some bonus points
Merge pull request #2 from equalsraf/tb-raf

Solution for #1