function buyTokens() public payable {
        require(block.timestamp > startIco && block.timestamp < startIco.add(periodIco));
        if (indCap > 0) {
            require(msg.value <= indCap.mul(1 ether));
        }
        uint256 totalAmount = msg.value.mul(10**8).div(rate).add(msg.value.mul(10**8).mul(getBonuses()).div(100).div(rate));
        uint256 balance = token.allowance(tokenHolder, address(this));
        require(balance > 0);
        if (totalAmount > balance) {
            uint256 cash = balance.mul(rate).mul(100).div(100 + getBonuses()).div(10**8);
            uint256 cashBack = msg.value.sub(cash);
            totalAmount = balance;
            msg.sender.transfer(cashBack);
        }
        multisig.transfer(msg.value + cash);
        token.transferFrom(tokenHolder, msg.sender, totalAmount);
        if (tokens[msg.sender] == 0) {
            addresses.push(msg.sender);
        }
        tokens[msg.sender] = tokens[msg.sender].add(totalAmount);
        _lock(msg.sender, tokens[msg.sender], startIco.add(periodIco).sub(block.timestamp));
        emit Purchased(msg.sender, totalAmount);
    }