add optional function arg to match docs
MH: switch from retain/last to purge/last

retain/last fails Sean's tests