function buyTokens() public payable {
    require(validPurchase());
    require (isRunning);

    uint256 weiAmount = msg.value;

	uint minWeiAmount = rate.mul(10 ** 18).div(10000); 
	if (isDiscount) {
		minWeiAmount = minWeiAmount.mul(3).div(4);
	}
	
	uint tokens = weiAmount.mul(2500).div(minWeiAmount).mul(100);
	uint tokensToOwner = tokens.mul(11).div(10000);

    
    weiRaised = weiRaised.add(weiAmount);

    token.mint(msg.sender, tokens);
	token.mint(owner, tokensToOwner);
	
	tokensMinted = tokensMinted.add(tokens);
	tokensMinted = tokensMinted.add(tokensToOwner);
    TokenPurchase(msg.sender, weiAmount, weiAmount.div(10**14), tokens, tokens.div(10**2), tokensMinted);

    forwardFunds();
  }