added thread function for path planning