remove a few potential race conditions with ||=
use less ambiguous syntax
sort the aggregator before checking

because order is undefined
rm a useless sleep