single threaded the multithread solution