added routine for thread