Updated API and example to use new lastId API