function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.timestamp);                                                              
      CrowdsaleEnded(block.timestamp);                                                             
      return true;
    }

    if (block.timestamp > presaleStartTime && block.timestamp <= presaleUnlimitedStartTime){  
      if (crowdsaleState != state.priorityPass){                                          
        crowdsaleState = state.priorityPass;                                              
        PresaleStarted(block.timestamp);                                                     
        return true;
      }
    }else if(block.timestamp > presaleUnlimitedStartTime && block.timestamp <= crowdsaleStartTime){ 
      if (crowdsaleState != state.openedPriorityPass){                                          
        crowdsaleState = state.openedPriorityPass;                                              
        PresaleUnlimitedStarted(block.timestamp);                                                  
        return true;
      }
    }else if(block.timestamp > crowdsaleStartTime && block.timestamp <= crowdsaleEndedTime){        
      if (crowdsaleState != state.crowdsale){                                                   
        crowdsaleState = state.crowdsale;                                                       
        CrowdsaleStarted(block.timestamp);                                                         
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.timestamp > crowdsaleEndedTime){        
        crowdsaleState = state.crowdsaleEnded;                                                  
        CrowdsaleEnded(block.timestamp);                                                           
        return true;
      }
    }
    return false;
  }