Implementation of recursion. Testing still required.