better way to implement DB connection