catch errors properly in thread pool