fixed disconnecting bug with sql