func: function buy(address _address, uint _value, uint _time) internal returns (bool){
      
      uint tokensToSend = etherToTokens(_value,_time);
  
      if (isPreIco(_time)){
        require (tokensToSend >= preIcoMinInvest);
        require (preIcoTokensSold.add(tokensToSend) <= preIcoMaxCap);
        
        token.sendCrowdsaleTokens(_address,tokensToSend);
        preIcoTokensSold = preIcoTokensSold.add(tokensToSend);
  
        tokensSold = tokensSold.add(tokensToSend);
        distributeEther();
  
      }else{
        require (tokensToSend >= icoMinInvest);
        token.sendCrowdsaleTokens(_address,tokensToSend);
  
        contributorBalances[_address] = contributorBalances[_address].add(_value);
  
        tokensSold = tokensSold.add(tokensToSend);
  
        if (tokensSold >= minCap){
          distributeEther();
        }
      }
  
      emit OnSuccessfullyBuy(_address,_value,true, tokensToSend);
      ethCollected = ethCollected.add(_value);
  
      return true;
    }