try and catch undef object exception