move logs out of try block