Better way of handling threading.