added catch for exceptions