working on thread handler code