I think at lesat the definition of dn should be moved into the catch block...