fixed SQL connection bug