function buyTokens(address beneficiary) whenNotPaused() payable {
    require(beneficiary != 0x0);
    require(msg.value != 0);
    require(now <= end);

    
    if ((weiRaised >= softCap * 1 ether) && gracePeriodStart == 0) 
      gracePeriodStart = block.timestamp;

    uint256 weiAmount = msg.value;

    
    uint256 tokens = weiAmount.mul(getRate());
    
    
    weiRaised = weiRaised.add(weiAmount);

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

    forwardFunds();
  }