re-structured the database connection factory