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

      AccreditedInvestor storage data = accredited[msg.sender];

      
      uint256 minInvest = data.minInvest;
      uint256 maxCumulativeInvest = data.maxCumulativeInvest;
      uint64 from = vestFromTime;
      uint64 cliff = from + data.cliff;
      uint64 vesting = cliff + data.vesting;
      bool revokable = data.revokable;
      bool burnsOnRevoke = data.burnsOnRevoke;

      uint256 tokens = msg.value.mul(rate);

      
      uint256 newBalance = balances[msg.sender].add(msg.value);
      require(newBalance <= maxCumulativeInvest && msg.value >= minInvest);

      if (data.cliff > 0 && data.vesting > 0) {
        require(QiibeeTokenInterface(token).mintVestedTokens(beneficiary, tokens, from, cliff, vesting, revokable, burnsOnRevoke, wallet));
      } else {
        require(QiibeeTokenInterface(token).mint(beneficiary, tokens));
      }

      
      balances[msg.sender] = newBalance;
      weiRaised = weiRaised.add(msg.value);
      tokensSold = tokensSold.add(tokens);

      TokenPurchase(msg.sender, beneficiary, msg.value, tokens);

      forwardFunds();
    }