added thread stuff (not done)