refine db connection