Add null checking for adding dialog