Fix bug with database connection