split up work into multiple functions, with common db class, and for loop now async