rework of main thread