added some try except logic