adding thread based parallel code