Corrected Database connection renewal logic