working threaded version
test -> demo