function investInternal(address receiver, uint128 customerId) stopInEmergency private {

    
    if(getState() == State.PreFunding) {
      
      require(earlyParticipantWhitelist[receiver]);
    } else if(getState() == State.Funding) {
      
      
    } else {
      
      assert(false);
    }

    uint weiAmount = msg.value;

    
    uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals());

    require(tokenAmount != 0); 

    if(investedAmountOf[receiver] == 0) {
       
       investorCount++;
    }

    
    investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
    tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);

    
    weiRaised = weiRaised.plus(weiAmount);
    tokensSold = tokensSold.plus(tokenAmount);

    if(pricingStrategy.isPresalePurchase(receiver)) {
        presaleWeiRaised = presaleWeiRaised.plus(weiAmount);
    }

    
    require(!isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold));

    assignTokens(receiver, tokenAmount);

    
    require(multisigWallet.send(weiAmount));

    
    Invested(receiver, weiAmount, tokenAmount, customerId);
  }