set client outside of try block