Added thread main