Debugged for iteration 5

Added if else to catch the null pointer exception to show a message.