added custom exception to optional chaining