maybe a loop helps, pick one by one until the last element in db is found