function investInternal(address receiver, uint128 customerId) stopInEmergency internal returns(uint tokensBought) {

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

    uint weiAmount = msg.value;

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

    
    require(tokenAmount != 0);
	
	
	if(tokenAmount < 50) revert(); 

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

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

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

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

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

    assignTokens(receiver, tokenAmount);

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

    
    Invested(receiver, weiAmount, tokenAmount, customerId);

    return tokenAmount;
  }