add lock for lastId in the client