function buyTokens(address beneficiary) canBuyTokens whenNotPaused payable {
        require(beneficiary != 0x0);
        require(msg.value >= 100 finney);

        uint256 weiAmount = msg.value;

        
        uint256 tokens = weiAmount.mul(rate);

        uint8 bonus = 0;

        if(preIcoActive) {
            bonus = 25; 
        }

        if( icoActive && block.timestamp - tgeDateStart <= 1 days){
            bonus = 15;
        }
        if(bonus > 0){
            tokens += tokens * bonus / 100;    
        }

        require(totalSupply_.add(tokens) <= maxTokenToBuy);

        require(mintInternal(beneficiary, tokens));

        TokenPurchase(msg.sender, beneficiary, tokens);

    forwardFunds();
    }