function buyTokens(address beneficiary, uint256 weiAmount) internal {
    require(beneficiary != address(0));
    require(validPurchase(weiAmount, token.totalSupply()));

    
    uint256 tokens = calculateTokens(token.totalSupply(), weiAmount);

    
    weiRaised = weiRaised.add(weiAmount);

    token.mint(beneficiary, tokens);
    TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

    forwardFunds(weiAmount);
  }