First version with multi threading