added  complete Threading, changed main