implemented thread for flashing