new version of the lib, multithread compliant