Fixed a small bug in getMaxPriority function.