changed variable name "max" to "m" (bad bad bad...)