added threads and stuff