TODO: use Scala concurrency tools instead