creating a new thread function