Database connection bug fix