Updated code with recursion

updated with recursion and running through all of the information