tried to make multithreaded and probably failed