Move consume callback to a function