fix race condition while scanning for hosts