handle db connections properly