got script working for exceptions and errors