Filter and format output