It now works for the base case. The code is still terribly structured though.