added dynamic thread handling during the computation