try {
        $limit = checkRateLim($connectionT);
        if ($limit > 0) {
            $level2 = $connectionT->get("followers/ids", array("user_id" => $user, "count" => '5000'));
            $array = $level2->ids;
            //print_r($array);
            if (is_array($array)) {
                $query = "DELETE FROM gather WHERE userID={$user}";
                if ($conn->query($query) === TRUE) {
                    saveThis($user, $array, $conn);
                    echo "Saved connection";
                }
            }
        } else {
            sleep(900);
            echo "No more data is available at this time";
            $level2 = $connectionT->get("followers/ids", array("user_id" => $user, "count" => '5000'));
            $array = $level2->ids;
            //print_r($array);
            if (is_array($array)) {
                $query = "DELETE FROM gather WHERE userID={$user}";
                if ($conn->query($query) === TRUE) {
                    saveThis($user, $array, $conn);
                    echo "Saved connections. Resuming Data Retrieval";
                }
            }
        }
    } catch (Exception $e) {
        echo "This is all the data for now";
    }
}
function saveConnections($loggedUser, $followerArray, $database, $twitConn)
{
    $user = $loggedUser;
    $followers = $followerArray;
    $conn = $database;
    $j = sizeof($followers);
    $connectionT = $twitConn;
    for ($i = 0; $i < $j; $i++) {
        $source = $followers[$i];
        $sqlquery = "Select * from userdata where source={$source} AND target={$user}";
        if ($result = mysqli_query($conn, $sqlquery)) {
            $row_cnt = mysqli_num_rows($result);
            if ($row_cnt == 0) {
                $query = "INSERT INTO userdata (source,target) VALUES({$source},{$user})";
                if ($conn->query($query) === TRUE) {
                    //echo "Saved connection";
                }
            }
        }
        $newQuery = "Select * from gather where userID={$source}";
        if ($result = mysqli_query($conn, $newQuery)) {
            $row_cnt = mysqli_num_rows($result);
            if ($row_cnt == 0) {
                $query = "INSERT INTO gather (userID) VALUES({$source})";
                if ($conn->query($query) === TRUE) {
                    //echo "Saved connection";
                }
            }
        }
    }
    $limit = checkRateLim($connectionT);
    $query = mysqli_query($conn, "Select * from gather");
    $array = array();
    while ($row = mysqli_fetch_assoc($query)) {
        // add each row returned into an array
        $array[] = $row;
    }
    $data = $array;
    print_r($data);
    $go = sizeof($data);
    for ($i = 0; $i < $go; $i++) {
        $userTemp = $data[$i];
        $user = $userTemp['userID'];
        //print_r($user);
        try {
            $limit = checkRateLim($connectionT);
            if ($limit > 0) {
                $level2 = $connectionT->get("followers/ids", array("user_id" => $user, "count" => '5000'));
                $array = $level2->ids;
                //print_r($array);
                if (is_array($array)) {
                    $query = "DELETE FROM gather WHERE userID={$user}";
                    if ($conn->query($query) === TRUE) {
                        saveThis($user, $array, $conn);
                        //echo "Saved connection";
                    }
                }
            } else {
                echo "No more data is available at this time";
            }
        } catch (Exception $e) {
            echo "This is all the data for now";
        }
    }
}