fix thread
encode