efficient dbap loop