protected function getValidPriority($desiredPriority)
    {
        // make sure the priority is an integer so we don't screw up the math
        // also multiply everything by 10000 because the priority must be an integer
        // as it will be used as the $filters[$selector] array key
        $desiredPriority = (int) $desiredPriority * 10000;
        if (! in_array($desiredPriority, $this->allocatedPriorities)) {
            return $desiredPriority;
        }
        // the increment will be used to determine when we find an available spot
        // obviously if you have 10000 filters with priority 0,
        // the 10000th will get to priority one but that's a chance we are willing to take
        $increment = 1;
        while (in_array($desiredPriority, $this->allocatedPriorities)) {
            $desiredPriority += $increment;
        }
        return $desiredPriority;
    }