Converted to a function.

Only argument is lam, which will let me experiment with different
lambda values easily.