Put getMaxPriority in a separate function.