first use of threads, need to clean code