now with lambda
updated script to accept lambda