Added if statement

Added if statement to prevent recursive call from being null.