Fixed the recursive function. Some functions still isolated.