improved db pipeline