Nest recursive function in outer function.

Neater, better encapsulation.