Got recursion sort of working, still very buggy