Fix Client not crashing

implemented thread
not sure if thread ok