implemented code to excerpt ad and count characters