add try catch to avoid null reference error