Update code add try except