Addition of try/catch to avoid main thread exception