added try-catch-exception checks.