Adding exception handling. Display the error and don't exit