Change max to min to ensure proper max task