fixed sql connection bug