improved db connection for easier use and portability