Extract collecting elements code