    function swap() external onlyWhitelisted {
        if (now >= _lastReset + _period) {
            _reset();
        }
        require(_remaining != 0, "swap: no tokens available");
        require(_infos[msg.sender].availableTokens != 0, "swap: no tokens available for swap");
        require(now >= _infos[msg.sender].lastSwapTimestamp + _period, "swap: msg.sender can not call this method now");
        uint256 toSwap = _infos[msg.sender].availableTokens;
        if (toSwap > _publicLimit) {
            toSwap = _publicLimit;
        }
        if (toSwap > _remaining) {
            toSwap = _remaining;
        }
        if (toSwap > _oldToken.balanceOf(msg.sender)) {
            toSwap = _oldToken.balanceOf(msg.sender);
        }
        _swap(toSwap);
        _update(toSwap);
        _remaining = _remaining.sub(toSwap);
        emit TokensSwapped(msg.sender, toSwap);
    }