repair getConnection function