Added dispatch-to-thread function