Actually, I don't think that this if is required since you are setting the dialog variable right after.