fixed SQL connection stuff