kwargs should be passed to func, shouldn't they? And max_percentage should be the first argument.