added multithreading. though it's not apparent whether there is an advantage.