Fixed off-by-one error when checking g.max.