Added multithreaded, cleaned-up version