fix potential bug

Variables created within try-catch statements can only be accessed
within the try-catch scope so initiate the variables outwit the scope