Update to use threads