Substituted lambda functions because of pickle problem