Added exception protection.