function buyTokens(address beneficiary) public payable {
    require(beneficiary != address(0));
    require(validPurchase());

    if (disabled) {
      pendingOrders[msg.sender] = pendingOrders[msg.sender].add(msg.value);
      forwardFunds();
      return;
    }

    uint256 weiAmount = msg.value;
    uint256 sold = totalSold();

    uint256 tokens;

    if (sold < _discount(25)) {
      tokens = _calculateTokens(weiAmount, 25, sold);
    }
    else if (sold >= _discount(25) && sold < _discount(20)) {
      tokens = _calculateTokens(weiAmount, 20, sold);
    }
    else if (sold >= _discount(20) && sold < _discount(15)) {
      tokens = _calculateTokens(weiAmount, 15, sold);
    }
    else if (sold >= _discount(15) && sold < _discount(10)) {
      tokens = _calculateTokens(weiAmount, 10, sold);
    }
    else if (sold >= _discount(10) && sold < _discount(5)) {
      tokens = _calculateTokens(weiAmount, 5, sold);
    }
    else {
      tokens = weiAmount.mul(rate);
    }

    
    require(sold.add(tokens) <= totalSupply);

    weiRaised = weiRaised.add(weiAmount);
    token.transferFrom(vault, beneficiary, tokens);
    TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

    forwardFunds();
  }