whoops, was using the max parameter for two purposes; fixed