Use functools.partial instead of lamba