counter is now moved to callback function