added try/catch and removed one writeline but added some others.