added explict exception checking.