Sorrounnd dismis() with try catch to avoid crash