Added try catch blocks