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

    
    State state = getState();
    if (state == State.Funding) {
      
    } else if (state == State.PreFunding) {
      
      if (!earlyParticipantWhitelist[receiver]) {
        throw;
      }
    } else {
      
      throw;
    }

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

    if (tokenAmount == 0) {
      
      throw;
    }

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

    
    investedAmountOf[receiver] = safeAdd(investedAmountOf[receiver], weiAmount);
    tokenAmountOf[receiver] = safeAdd(tokenAmountOf[receiver], tokenAmount);

    
    uint256 personalWeiLimit = smallCapLimitOf[receiver];
    if (block.timestamp > startsAt + largeCapDelay) {
      personalWeiLimit = safeAdd(personalWeiLimit, largeCapLimitOf[receiver]);
    }
    if (investedAmountOf[receiver] > personalWeiLimit) {
      throw;
    }

    
    weiRaised = safeAdd(weiRaised, weiAmount);
    tokensSold = safeAdd(tokensSold, tokenAmount);

    
    if (isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) {
      throw;
    }

    assignTokens(receiver, tokenAmount);

    
    if (!multisigWallet.send(weiAmount)) throw;

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