support lambda
added error handling