made finding  max prio more compact