update lambda code; reduce memory allocation