added --max flag