replacing unnecessarily locking cout usage with a more elegant and less potentially MT-problematic solution