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

    
    if(getState() == State.PreFunding) {
      
      if(!earlyParticipantWhitelist[receiver]) {
        throw;
      }
    } else if(getState() == State.Funding) {
      
      
    } 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] = investedAmountOf[receiver].plus(weiAmount);
    tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);

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


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

    assignTokens(receiver, tokenAmount);

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

    
    Invested(receiver, weiAmount, tokenAmount, customerId);

  }