added background thread to collect stats