bah, that recursion looks way better :/