function getCurrentMilestoneIndex() internal view onlyWhileOpen returns  (uint256) {
        uint256 index;

        
        
        
        for(uint i = 0; i < milestoneCount; i++) {
            index = i;
            
            if(block.timestamp < milestones[i].startTime) {
                index = i - 1;
                break;
            }
        }

        
        
        
        if (milestones[index].tokensSold > milestones[index].cap) {
            index = index + 1;
        }

        return index;
    }