function buyTokens() public payable {
        require(block.timestamp > startIco && block.timestamp < startIco.add(periodIco));

        if (indCap > 0) {
            require(msg.value <= indCap.mul(1 ether));
        }

        uint256 amount = msg.value.mul(10**8).div(rate);
        uint256 balance = token.balanceOf(this);

        if (amount > balance) {
            uint256 cash = balance.mul(rate).div(10**8);
            uint256 cashBack = msg.value.sub(cash);
            multisig.transfer(cash);
            msg.sender.transfer(cashBack);
            token.transfer(msg.sender, balance);
            emit Purchased(msg.sender, balance, "MainICO");
            return;
        }

        multisig.transfer(msg.value);
        token.transfer(msg.sender, amount);
        emit Purchased(msg.sender, amount, "MainICO");
    }