fixing database connection bug