lambda instead of global counter