added try block and debug print