added exceptions
added try/catch blocks