Changed closure to functools.partial