some try..catch codes replaced with checks.