refactoring e supporto multi-threading