reworked the database connection